@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')
    <div class="layui-card-body">
        <div class="layui-input-inline layui-show-xs-block">

            <a class="layui-btn layui-btn-small" style="line-height:1.6em;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>礼包类型</th>
                                {{--<th>状态</th>--}}
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                                <tr class="phono_ine">
                                    <td>{{ $key + 1 }}</td>
                                    <td>{{ $value['name'] }}</td>
                                    {{--<td> <input type="checkbox" name="status" data-id="{{$value['id']}}" data-status="{{$value['status']}}" lay-skin="switch" lay-filter="switchTest" @if( $value['status'] == 0 ) checked="" @endif lay-text="启用|禁用" >该控制功能还没有完善，还未确定控制参数存放位置 </td>--}}
                                    <td class="td-manage">
                                        <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑礼包','{{route("admin_gift_edit",["type"=>$value["type"] , 'age'=>$value["age"]])}}')" href="javascript:;">
                                            编辑 </a>
                                    </td>
                                </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //列表点击查看大图
            $("body").on('click','.look_img',function(e){
                layer.photos({
                    photos: '.phono_ine' //格式见API文档手册页
                    ,anim: 1 //0-6的选择，指定弹出图片动画类型，默认随机
                });
            })

            form.on('switch(switchTest)', function(data){
                var id = $(this).attr('data-id');
                var status = 1;
                if( $(this).attr('data-status') == 1 ){
                    status = 2;
                }
                $.ajax({
                    url: js_url('admin-banner-update'),
                    type: 'post',
                    data: {id:id,status:status,'_token': '{{csrf_token()}}'},
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 500, icon: 6}, function () {
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
            });

        })
    </script>
@endsection




